/**
 * author:Administrator
 * date:2013-5-21
 */
package com.roc.web.action.terminal;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;


@SuppressWarnings("serial")
public class PayTreasureTerminalSearchCondition extends BaseSearchCondition {
	

	private String orgCode;
	private String merchantNo;
	private String merchantName;
	private String tid;
	private String flag;
	private String terminalSn;	
	private String obj;

	@Override
	protected String getOrderPartOfHQL() {		
		return " order by a.mcht_cd, b.term_id desc ";
	}


	@Override
	protected String getRowCountHQL() {//,OrgBean o  t.orgCode = o.org_code
		StringBuffer sb=new StringBuffer();
		sb.append(" select count(*) from tbl_mcht_inf a,tbl_term_inf b where a.mcht_cd=b.mcht_cd and a.group_cd = '3' ");
		sb.append(" and b.status = '01'  and instr(b.DEVICE_CD, 'YJ') <= 0 and b.REC_UPD_TS is not null  ");
		return sb.toString();
	}


	@Override
	protected String getSearchHQL() {
		   
		StringBuffer sb=new StringBuffer();
		sb.append(" select a.bank_belong_cd,a.mcht_cd,a.name_busi,a.name,b.term_id,b.term_tp,b.status,b.device_cd ");
		sb.append(" from tbl_mcht_inf a,tbl_term_inf b where a.mcht_cd=b.mcht_cd and a.group_cd = '3' ");
		sb.append(" and b.status = '01'  and instr(b.DEVICE_CD, 'YJ') <= 0 and b.REC_UPD_TS is not null  ");
		return sb.toString();
	}


	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();		
		if (Constance.isNotEmpty(orgCode)) {		
			filedBeanList.add(new WhereHQLFieldBean("a.bank_belong_cd",orgCode.trim(), "=", false));
		}
		if (Constance.isNotEmpty(merchantName)) {
			filedBeanList.add(new WhereHQLFieldBean("a.name_busi", merchantName.trim(),"LIKE", false,"ALL"));
		}
		if (Constance.isNotEmpty(merchantNo)) {
			filedBeanList.add(new WhereHQLFieldBean("a.mcht_cd", merchantNo.trim(), "=", false));
		}
		if (Constance.isNotEmpty(tid)) {
			filedBeanList.add(new WhereHQLFieldBean("b.term_id", tid, "=", false));
		}
		if (Constance.isNotEmpty(flag)) {
			filedBeanList.add(new WhereHQLFieldBean("b.status", flag, "=", false));
		}
		if (Constance.isNotEmpty(terminalSn)) {
			filedBeanList.add(new WhereHQLFieldBean("b.device_cd", terminalSn.trim(), "=", false));
		}
		return filedBeanList;
	}


	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	public String getMerchantName() {
		return merchantName;
	}

	public void setMerchantName(String merchantName) {
		this.merchantName = merchantName;
	}

	public String getTid() {
		return tid;
	}

	public void setTid(String tid) {
		this.tid = tid;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public String getTerminalSn() {
		return terminalSn;
	}

	public void setTerminalSn(String terminalSn) {
		this.terminalSn = terminalSn;
	}

	public String getObj() {
		return obj;
	}

	public void setObj(String obj) {
		this.obj = obj;
	}
	
}
